/**
 *查询时段报表与搜索框的模糊查询，有模糊查询，传日期名称字段
 */

var Grid = BUI.Grid,
    Store = BUI.Data.Store,
    columns = [
        {
            title: '序号', dataIndex: 'flowDailyReportId',width:'15%',renderer: function (value,obj,index) {
                return index+1;
            }
        },
        {title: '设备名称', dataIndex: 'deviceName',width:'25%'},
        {title: '上日读数', dataIndex: 'beginWaterAmount',width:'15%', renderer: function (value) {
                return (parseInt(value)+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');

            }},
        {title: '今日读数', dataIndex: 'endWaterAmount',width:'15%', renderer: function (value) {

                return (parseInt(value)+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');

            }},
        {title: '水量', dataIndex: 'waterAmount',width:'15%', renderer: function (value) {

                return (value+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');

            }},
        {title: '系数', dataIndex: 'factor',width:'15%'}
    ];
//分页查询
var store = new Store({
        url: '/rest/web/flowDailyReport/selectFlowSecondReportPage',
        autoLoad: true, //自动加载数据
        params: { //配置初始请求的参数
            length: '15',
            start: '0',
            startTime: new Date(new Date()).Format1("yyyy-MM-dd hh:mm:ss"),
            endTime:new Date(new Date()).Format("yyyy-MM-dd hh:mm:ss")
        },
        pageSize: 15,	// 配置分页数目
        root: 'data.list',
        totalProperty: 'data.totalCount'
    }),
    grid = new Grid.Grid({
        render: '#grid',
        columns: columns,
        loadMask: true, //加载数据时显示屏蔽层
        store: store,
        plugins: [Grid.Plugins.CheckSelection], // 插件形式引入多选表格
        // 底部工具栏
        bbar: {
            pagingBar: true
        }
    });

grid.render();

/**模糊搜索**/
var form = new BUI.Form.HForm({
    srcNode: '#searchForm'
}).render();

form.on('beforesubmit', function (ev) {
    //序列化成对象
    var obj = form.serializeToObject();
    obj.start = 0; //返回第一页
    store.load(obj);
    return false;
});


